<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收藏列表</title>
    <style>
        body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
}

hr {
    border: 0;
    height: 1px;
    background-color: #ccc;
    margin: 20px 0;
}

a {
    text-decoration: none;
    color: #007bff;
}

a:hover {
    text-decoration: underline;
}
</style>
</head>
<body>
    <h2>商品收藏列表</h2>
    <hr>
    <form action="" method="post">
        {% csrf_token %}
        <button type="submit" name="sort_by" value="quantity">按数量排序</button>
        <button type="submit" name="sort_by" value="name">按名称排序</button>
        <button type="submit" name="sort_by" value="add_at">按时间顺序</button>
        <button type="submit" name="sort_by" value="price">按总价排序</button>
    </form>
    <ul>
        {% for cart in carts %}
            <a href="{% url 'cart:cart_detail' cart.id%}">
                <ul>
                    <p>
                    {{cart.product.name}}
                    {{cart.quantity}} 件
                    总价:{% widthratio cart.quantity 1 cart.product.price %}
                    添加时间:{{cart.add_at|date:"Y年-m月-d日 H:i:s"}}
                    </p>
                </ul>
            </a>
        {% endfor %}
    </ul>
<a href="{% url 'product:product_list' %}">返回商品列表</a>
<a href="{% url 'user:index' %}">返回首页</a>
</body>
</html>